package com.ym.health.api.doctor.self;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ym.base.enums.FlagEnum;
import com.ym.common.annotations.CustomConstraint;
import com.ym.common.constant.Constants;
import com.ym.common.constant.ValidRule;
import com.ym.core.annotation.ApiSign;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.core.shiro.ShiroUtil;
import com.ym.core.utils.tkmybatis.TK;
import com.ym.medical.domain.entity.DoctorStudioEntity;
import com.ym.medical.domain.entity.DoctorStudioPricingEntity;
import com.ym.medical.domain.entity.DsAdviseRecordEntity;
import com.ym.medical.domain.entity.OpenStudioAppEntity;
import com.ym.medical.domain.entity.ServiceTermsEntity;
import com.ym.medical.domain.entity.StudioPersonServiceEntity;
import com.ym.medical.domain.entity.StudioPersonnelEntity;
import com.ym.medical.domain.entity.StudioRelatedFormEntity;
import com.ym.medical.domain.param.DoctorSearchParam;
import com.ym.medical.domain.vo.DoctorStudioInfoVo;
import com.ym.medical.domain.vo.DoctorStudioStatusViewVo;
import com.ym.medical.domain.vo.DoctorStudioVo;
import com.ym.medical.domain.vo.FriendWorkDetailOrderVo;
import com.ym.medical.domain.vo.FriendWorkDetailVo;
import com.ym.medical.domain.vo.MyStudioDocotVo;
import com.ym.medical.domain.vo.MyStudioDoctorInforVo;
import com.ym.medical.domain.vo.ResultDoctor;
import com.ym.medical.domain.vo.StudioRelatedFormVo;
import com.ym.medical.enums.CounsellingRoomCourTypeEnum;
import com.ym.medical.enums.DoctorServiceItemEnum;
import com.ym.medical.enums.JoinStudioServTypeEnum;
import com.ym.medical.service.*;
import com.ym.spring.SessionContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = "医生端-个人中心-工作室")
@RestController
@ApiSign
@RequestMapping(value = "/doctor/self/doctorStudio",headers = Constants.Api.VERSION)
@Validated
public class DoctorStudioController extends BaseController {

	@Autowired
	private IStudioPersonnelSV studioPersonnelSV;

	@Autowired
	private IOpenStudioAppSV openStudioAppSV;

	@Autowired
	private IDoctorStudioSV doctorStudioSV;

	@Autowired
	private IDoctorStudioPricingSV doctorStudioPricingSV;

	@Autowired
	private ICommonSV commonSV;

	@Autowired
	private IStudioRelatedFormSV studioRelatedFormSV;

	@Autowired
	private IDoctorDetailsSV doctorDetailsSV;

	@Autowired
	private IStudioPersonServiceSV studioPersonServiceSV;

	@Autowired
	private IServiceTermsSV serviceTermsSV;

	@Autowired
	private IDsAdviseRecordSV dsAdviseRecordSV;

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "对我的工作室成员设置信息查询")
	@GetMapping(value = "/queryMyStudioDoctor", produces = "application/json;charset=UTF-8")
	public APIResponse<MyStudioDocotVo> queryMyStudioDoctor(
			@RequestParam @ApiParam("我的工作室中医生ID") Long doctId) {
		MyStudioDocotVo myStudioDocotVo = new MyStudioDocotVo();
		DoctorStudioEntity doctorStudio = SessionContext.getCurrDoctorStudio();
		StudioPersonnelEntity studioPersonnel = studioPersonnelSV.selectOne(
				TK.select(StudioPersonnelEntity.class)
						.where()
						.andEqualTo(StudioPersonnelEntity::getDsId, doctorStudio.getId())
						.andEqualTo(StudioPersonnelEntity::getDoctId, doctId)
						.end()
		);

		// 工作室成员
		List<StudioPersonServiceEntity> studioPersonServices = studioPersonServiceSV.selectList(
				TK.select(StudioPersonServiceEntity.class)
						.where()
						.andEqualTo(StudioPersonServiceEntity::getStudioPersonId, studioPersonnel.getId())
						.end()
		);

		myStudioDocotVo.setStudioPersonnel(studioPersonnel);
		myStudioDocotVo.setStudioPersonServices(studioPersonServices);
		return successData(myStudioDocotVo);
	}

	@Log
	@ApiOperation(value = "对我的工作室成员设置")
	@PostMapping(value = "/updateMyStudioDoctor", consumes = MediaType.APPLICATION_JSON_VALUE)
	public APIResponse updateMyStudioDoctor(
			@RequestBody StudioPersonnelEntity studioPersonnel) {
		studioPersonnelSV.updateByParams(studioPersonnel,
				TK.selectWhere(StudioPersonnelEntity.class)
						.andEqualTo(StudioPersonnelEntity::getDsId, studioPersonnel.getDsId())
						.andEqualTo(StudioPersonnelEntity::getDoctId, studioPersonnel.getDoctId())
				.end()
		);
		return success();
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "友医工作室中我的消息设置查询")
	@GetMapping(value = "/queryOtherStudioDoctor")
	public APIResponse<StudioPersonnelEntity> queryOtherStudioDoctor(
			@RequestParam Long dsId
	) {
		StudioPersonnelEntity studioPersonnel = studioPersonnelSV.selectOne(
				TK.select(StudioPersonnelEntity.class)
						.where()
						.andEqualTo(StudioPersonnelEntity::getDsId, dsId)
						.andEqualTo(StudioPersonnelEntity::getDoctId, ShiroUtil.getLoginId())
						.end()
		);
		return successData(studioPersonnel);
	}

	@Log
	@ApiOperation(value = "对友医工作室中我的消息设置")
	@PostMapping(value = "/updateOtherStudioDoctor", consumes = MediaType.APPLICATION_JSON_VALUE)
	public APIResponse updateOtherStudioDoctor(@RequestBody StudioPersonnelEntity studioPersonnel) {
		studioPersonnelSV.updateByParams(studioPersonnel,
				TK.selectWhere(StudioPersonnelEntity.class)
						.andEqualTo(StudioPersonnelEntity::getDsId, studioPersonnel.getDsId())
						.andEqualTo(StudioPersonnelEntity::getDoctId, ShiroUtil.getLoginId())
				.end()
		);
		return success();
	}

	@Log
	@ApiOperation(value = "对我的所有友医工作室消息设置")
	@PostMapping(value = "/updateAllStudioDoctor")
	public APIResponse updateAllStudioDoctor(@RequestBody @Validated(value = {ValidRule.Update.class}) StudioPersonnelEntity studioPersonnel) {
		studioPersonnelSV.updateByParams(studioPersonnel, TK.selectWhere(StudioPersonnelEntity.class).andEqualTo(StudioPersonnelEntity::getDoctId, ShiroUtil.getLoginId()).end());
		return success();
	}

	@Log
	@ApiOperation(value = "工作室申请")
	@PostMapping(value = "/saveStudioApp")
	public APIResponse saveStudioApp(@RequestBody @Validated OpenStudioAppEntity openStudioApp) {
		openStudioAppSV.saveStudioApp(openStudioApp, ShiroUtil.getLoginId());
		return success();
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "工作室申请查看")
	@GetMapping(value = "/viewStudioApp")
	public APIResponse<List<OpenStudioAppEntity>> viewStudioApp() {
		List<OpenStudioAppEntity> openStudioApps = openStudioAppSV.selectList(OpenStudioAppEntity.builder().doctId(ShiroUtil.getLoginId()).build());
		return successData(openStudioApps);
	}

	@Log
	@ApiOperation(value = "工作室信息修改")
	@PostMapping(value = "/saveDoctorStudio", consumes = MediaType.APPLICATION_JSON_VALUE)
	public APIResponse saveDoctorStudio(@RequestBody DoctorStudioEntity doctorStudio) {
		doctorStudioSV.updateById(doctorStudio);
		return success();
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "工作室分成信息查询")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "doctId", value = "doctId非空，则查询其他医生工作室的分成信息，否则查询自己工作室的分成信息", required = false, paramType = "query"),
	})
	@GetMapping(value = "/queryDoctorStudioPricing")
	public APIResponse<List<DoctorStudioPricingEntity>> queryDoctorStudioPricing(
			Long doctId
	) {
		if (doctId == null) {
			doctId = ShiroUtil.getLoginId();
		}
		List<DoctorStudioPricingEntity> doctorStudioPricings = doctorStudioPricingSV.queryDoctorStudioPricing(doctId, true);
		return successData(doctorStudioPricings);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "友医工作室开通服务项查询")
	@GetMapping(value = "/studioOpeningServiceItem")
	public APIResponse<List<DoctorStudioPricingEntity>> studioOpeningServiceItem(
			@ApiParam("医生ID") @RequestParam Long doctId,
			@ApiParam("工作室ID") @RequestParam Long dsId
	) {
		if (doctId == null) {
			doctId = ShiroUtil.getLoginId();
		}
		List<DoctorStudioPricingEntity> doctorStudioPricings = studioPersonServiceSV.studioOpeningServiceItem(doctId, dsId);
		return successData(doctorStudioPricings);
	}

	@Log
	@ApiOperation(value = "友医工作室开通服务项设置")
	@PostMapping(value = "/openServiceItemSettings", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
	public APIResponse openServiceItemSettings(
			@ApiParam("服务项ID") @NotNull Long id,
			@ApiParam("状态00关闭01开启") @CustomConstraint(value = FlagEnum.class) String state
	) {
		StudioPersonServiceEntity studioPersonService = new StudioPersonServiceEntity();
		studioPersonService.setId(id);
		studioPersonService.setState(state);
		studioPersonServiceSV.updateById(studioPersonService);
		return success();
	}


	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "工作室相关状态查看")
	@GetMapping(value = "/studioRelatedStatusView")
	public APIResponse<DoctorStudioStatusViewVo> studioRelatedStatusView() {
		DoctorStudioStatusViewVo doctorStudioStatusViewVo = doctorStudioSV.studioRelatedStatusView(ShiroUtil.getLoginId());
		return successData(doctorStudioStatusViewVo);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "工作室信息查询")
	@GetMapping(value = "/queryDoctorStudio", produces = "application/json;charset=UTF-8")
	public APIResponse<DoctorStudioInfoVo> queryDoctorStudio(
			@ApiParam("doctId为空，查询自己的工作室信息.否则查询其他医生工作室信息") Long doctId
	) {
		if (StringUtils.isEmpty(doctId)) {//当前医生的工作室
			doctId = ShiroUtil.getLoginId();
		}
		DoctorStudioInfoVo doctorStudioInfoVo = doctorStudioSV.queryDoctorStudio(doctId);
		return successData(doctorStudioInfoVo);
	}

	@Log
	@ApiOperation(value = "工作室分成信息修改")
	@PostMapping(value = "/saveDoctorStudioPricing", consumes = MediaType.APPLICATION_JSON_VALUE)
	public APIResponse saveDoctorStudioPricing(
			@RequestBody @Validated DoctorStudioPricingEntity doctorStudioPricing
	) throws Exception {
		Long id = doctorStudioPricingSV.saveDoctorStudioPricing(doctorStudioPricing, ShiroUtil.getLoginId());
		return successData(id);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "我的工作室成员列表信息查询")
	@GetMapping(value = "/queryMyStudioDoctorInfor", produces = "application/json;charset=UTF-8")
	public APIResponse<List<MyStudioDoctorInforVo>> queryMyStudioDoctorInfor() {
		DoctorStudioEntity doctorStudio = doctorStudioSV.selectOne(DoctorStudioEntity.builder().belongPerson(ShiroUtil.getLoginId()).build());
		String sql = "SELECT  " +
				" b.id,  " +
				" a.id dsId,  " +
				" b.doct_id doctId,  " +
				" c.head_url doctPhotoUrl,  " +
				" c.real_name realName,  " +
				" c.dept_name deptName,  " +
				" c.job_title jobTitle,  " +
				" c.hos_name hosName,  " +
				" c.hos_level hosLevel,  " +
				" b.adms_State_Studio diagnStatus,  " +
				" b.create_time joinTime,  " +
				" h.orderNum,  " +
				" d.price,  " +
				" d1.proportion,  " +
				" d1.state,  " +
				" d1.service_id serviceId,  " +
				" f.label goodsLabel,  " +
				" g.label patientLabel  " +
				"from doctor_studio a  " +
				"left join studio_personnel b on a.id = b.ds_id  " +
				"left join user_doctor_view c on c.id = b.doct_id  " +
				"LEFT JOIN studio_person_service d1 on d1.studio_person_id = b.id  " +
				"LEFT JOIN (" +
				" select d.doct_id,d.dsp_price price  " +
				" from doctor_service_price d  " +
				" LEFT JOIN  text_rule tr on tr.id = d.rule_id where d.state = '01' and d.seri_label = '01' and tr.tr_type = '01' " +
				") d on d.doct_id = a.belong_person " +
				"left join (    " +
				" select fa.doct_id id ,group_concat(fb.dl_value) label    " +
				" from doctor_label fa    " +
				" inner join labels fb on fa.lab_id = fb.id and dl_type = '01'   " +
				" group by fa.doct_id    " +
				") f on f.id = b.doct_id    " +
				"left join (    " +
				" select ga.doct_id id ,group_concat(gb.dl_value) label    " +
				" from doctor_label ga    " +
				" inner join labels gb on ga.lab_id = gb.id and dl_type = '02'  " +
				" group by ga.doct_id    " +
				") g on g.id = b.doct_id    " +
				" LEFT JOIN (  " +
				"      select  " +
				"      count(0) orderNum,doctor_id doctorId,doctor_ds_id dsId  " +
				"      from order_flow_record_view where status > '03' and doctor_ds_id is not null  " +
				"      group by doctorId,dsId  " +
				"  ) h on h.dsId = a.id and h.doctorId = b.doct_id " +
				" where a.id = #{params.id} order by rel_type";
		Map<String, Object> params = new HashMap<>();
		params.put("id", doctorStudio.getId());
		params.put("doctorId", ShiroUtil.getLoginId());
		params.put("serviceId", DoctorServiceItemEnum.BY_INQUIRING.getKey());
		List<MyStudioDoctorInforVo> myStudioDoctorInforVos = commonSV.queryListEntity(sql, params, MyStudioDoctorInforVo.class);
		return successData(myStudioDoctorInforVos);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "查看邀请或申请的加入工作室或申请开通服务项的申请")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "申请的ID", required = true, paramType = "query"),
	})
	@GetMapping(value = "/queryJoinStudioAppServ")
	public APIResponse<StudioRelatedFormVo> queryJoinStudioAppServ(@RequestParam Long id) {
		StudioRelatedFormVo studioRelatedFormVo = studioRelatedFormSV.queryJoinStudioAppServ(id);
		return successData(studioRelatedFormVo);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "已加入的友医工作室列表查看")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "keywords", value = "关键词", required = false, paramType = "query"),
	})
	@GetMapping(value = "/friendStudioListView")
	public APIResponse<PageInfo<DoctorStudioVo>> friendMedicalStudioListView(
			String keywords,
			@RequestParam(defaultValue = "1") int pageNum,
			@RequestParam(defaultValue = "5") int pageSize
	) {
		PageHelper.startPage(pageNum, pageSize);
		List<DoctorStudioVo> doctorStudios = doctorStudioSV.friendMedicalStudioList(keywords, ShiroUtil.getLoginId());
		return successData(new PageInfo<>(doctorStudios));
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "友医工作室详情-接单量")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "doctorId", value = "医生ID", required = false, paramType = "query"),
			@ApiImplicitParam(name = "dsId", value = "工作室ID", required = true, paramType = "query"),
	})
	@GetMapping(value = "/friendStudioDetail/orders/count")
	public APIResponse<FriendWorkDetailVo> friendStudioDetailOrdersCount(
			Long doctorId,
			@NotNull Long dsId
	) {
		if (doctorId == null) {
			doctorId = ShiroUtil.getLoginId();
		}
		FriendWorkDetailVo doctorStudios = doctorStudioSV.friendStudioDetailOrdersCount(doctorId, dsId);
		return successData(doctorStudios);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "友医工作室详情-账单明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "doctorId", value = "医生ID", required = false, paramType = "query"),
			@ApiImplicitParam(name = "dsId", value = "工作室ID", required = true, paramType = "query"),
			@ApiImplicitParam(name = "status", value = "01已结单02未结单", required = true, paramType = "query"),
	})
	@GetMapping(value = "/friendStudioDetailView")
	public APIResponse<PageInfo<FriendWorkDetailOrderVo>> friendStudioDetailView(
			Long doctorId,
			@NotNull Long dsId,
			@NotNull String status,
			@RequestParam(defaultValue = "1") int pageNum,
			@RequestParam(defaultValue = "5") int pageSize
	) {
		PageHelper.startPage(pageNum, pageSize);
		if (doctorId == null) {
			doctorId = ShiroUtil.getLoginId();
		}
		List<FriendWorkDetailOrderVo> doctorStudios = doctorStudioSV.friendStudioDetailOrders(doctorId, dsId, status);
		return successData(new PageInfo<>(doctorStudios));
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "查询未加入的工作室列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "工作室ID", required = false, paramType = "query"),
			@ApiImplicitParam(name = "keywords", value = "关键词", required = false, paramType = "query"),
	})
	@GetMapping(value = "/searchQueryStudioList")
	public APIResponse<PageInfo<DoctorStudioVo>> searchQueryStudioList(
			String keywords,
			Long id,
			@RequestParam(defaultValue = "1") int pageNum,
			@RequestParam(defaultValue = "5") int pageSize
	) {
		PageHelper.startPage(pageNum, pageSize);
		List<DoctorStudioVo> doctorStudios = doctorStudioSV.searchQueryStudioList(id, keywords, ShiroUtil.getLoginId());
		PageInfo<DoctorStudioVo> doctorStudioVoPageInfo = new PageInfo<>(doctorStudios);
		return successData(doctorStudioVoPageInfo);
	}

	@Log
	@ApiOperation(value = "申请或邀请用户加入工作室或开通服务项")
	@PostMapping(value = "/applyToJoinTheStudio", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public APIResponse<Long> applyToJoinTheStudio(
			@RequestBody StudioRelatedFormEntity studioRelatedForm
	) {
		Long doctorId = studioRelatedForm.getDoctorId();
		if (doctorId == null) {
			doctorId = ShiroUtil.getLoginId();
		}
		studioRelatedForm.setDoctorId(doctorId);
		studioRelatedFormSV.applyToJoinTheStudio(studioRelatedForm, doctorId);
		return successData(studioRelatedForm.getId());
	}


	@Log
	@ApiOperation(value = "审核工作室相关申请")
	@PostMapping(value = "/reviewStudioRelatedApplication", consumes = MediaType.APPLICATION_JSON_VALUE)
	public APIResponse reviewStudioRelatedApplication(
			@RequestBody StudioRelatedFormEntity studioRelatedForm,
			@RequestParam Long informationId
	) throws Exception {
		Long id = studioRelatedForm.getId();
		String checkState = studioRelatedForm.getState();
		String sign = studioRelatedForm.getPartaSign();
		String reviewOpinion = studioRelatedForm.getReviewOpinion();
		studioRelatedFormSV.checkJoinStudioServApp(id, informationId, checkState, sign, reviewOpinion);
		return success();
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "工作室邀请医生,医生列表查询")
	@GetMapping("/platform/members")
	public APIResponse<PageInfo<ResultDoctor>> platformMembers(
			DoctorSearchParam query,
			@RequestParam(defaultValue = "1") int pageNum,
			@RequestParam(defaultValue = "5") int pageSize
	) {
		// 推荐记录ID设置
		if (query.getAdviseId() != null) {
			List<DsAdviseRecordEntity> dsAdviseRecords = dsAdviseRecordSV.selectList(TK.select(DsAdviseRecordEntity.class).column("beadvised_doctor_id")
					.where()
					.andIn(DsAdviseRecordEntity::getId,query.getAdviseId())
					.end()
			);
			query.setAdviseId(dsAdviseRecords.stream().map(DsAdviseRecordEntity::getBeadvisedDoctorId).toArray(Long[]::new));
		}
		query.setCurrUserId(ShiroUtil.getLoginId());
		query.setDoctCategory(CounsellingRoomCourTypeEnum.SPECIALIZED_SUBJECT.getKey());
		PageHelper.startPage(pageNum, pageSize);
		List<ResultDoctor> data = doctorDetailsSV.listStudioMembers(query);
		return successData(new PageInfo<>(data));
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "工作室审核列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "joinType", value = "加入类型，KEY=JoinStudioServTypeEnum", required = true, paramType = "query"),
	})
	@GetMapping("/studioReviewList")
	public APIResponse<PageInfo<StudioRelatedFormVo>> studioReviewList(
			@RequestParam(defaultValue = "1") int pageNum,
			@RequestParam(defaultValue = "5") int pageSize,
			@RequestParam @CustomConstraint(JoinStudioServTypeEnum.class) String joinType
	) {
		PageInfo<StudioRelatedFormVo> studioRelatedFormPageInfo = studioRelatedFormSV.studioReviewList(ShiroUtil.getLoginId(), joinType, pageNum, pageSize);
		return successData(studioRelatedFormPageInfo);
	}

	@Log(dataBase = false, printBody = false)
	@ApiOperation(value = "服务条款展示")
	@ApiSign(isSign = false)
	@GetMapping("/serviceTerms/list")
	public APIResponse<ServiceTermsEntity> listServiceTerms(@ApiParam(name = "type", value = "服务条款类型 01- 诊所违规行为及处罚原则说明  " +
			"02- 答题攻略大揭秘：如何才能获得“满意”评价 " +
			"03- 收入结算及账单查询 " +
			"04- 操作中遇到问题该怎么办？ " +
			"05- 常见问题及其处理措施 " +
			"06- 如何开启自己的诊所 " +
			"07- 加入工作室协议 " +
			"08- 前言，致每一位亚米医生 " +
			"09- 亚米医生法务条款 " +
			"10- 亚米问诊协议 " +
			"11- 工作室协议 " +
			"12- 法律声明及隐私权政策 " +
			"13- 亚米账号激活协议" +
			"14-用户隐私授权协议" +
			"15-电话问诊支付协议" +
			"16-图文问诊支付协议" +
			"17-健康币规则" +
			"18-测his" +
			"19-服务协议及隐私权政策" +
			"20-亚米健康用户注册协议" +
			"21-亚米健康用户隐私政策")
													  @RequestParam(required = false) String type) {
		List<ServiceTermsEntity> serviceTerms = serviceTermsSV.selectList(ServiceTermsEntity.builder().state(FlagEnum.IS.getKey()).termsName(type).build());
		return successData((serviceTerms.isEmpty()) ? null : serviceTerms.get(0));
	}
}
